/**
 * 
 */
package de.cbf.cam.dsa.model.prerequisites;

import java.util.List;

import de.cbf.cam.dsa.model.entities.BattleChar;
import de.cbf.cam.dsa.model.entities.OneNPC;
import de.cbf.cam.dsa.model.entities.ParameterSF;
import de.cbf.cam.dsa.model.entities.SF;

/**
 * @author Nebelritter
 *
 */
public class ParameterSFPrereq extends SfPrereq {
	/**
	 * @uml.property  name="parameter"
	 */
	protected String parameter;

	public ParameterSFPrereq(String sfName,String parameter) {
		super(sfName);
		this.parameter = parameter;
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.model.prerequisites.Prereq#characterMeetsPrereq(de.cbf.cam.dsa.model.entities.OneNPC)
	 */
	@Override
	public boolean characterMeetsPrereq(OneNPC character) {
		boolean success = super.characterMeetsPrereq(character);
		List<SF> sfs = character.getSFs();
		for(int i = 0;i<sfs.size();i++){
			SF sf = sfs.get(i);
			if (sf instanceof ParameterSF) {
				ParameterSF parameterSF = (ParameterSF) sf;
				if(parameterSF.getParameter().equals(parameter)&&success){
					return true ;
				}				
			}			
		}		
		return false;
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.model.prerequisites.Prereq#characterMeetsPrereq(de.cbf.cam.dsa.model.entities.BattleChar)
	 */
	@Override
	public boolean characterMeetsPrereq(BattleChar character) {
		return characterMeetsPrereq(character.getCharacter());
	}

	
}
